/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package circuit1;

/**
 *
 * @author Erik
 */
import java.awt.*;

public class CompositeUI implements IView{
    private Composite comp;
    private String ID;
    private int pos;
    
    /**
     * Konstruktor, ertekek beallitasa
     * @param e
     * @param n 
     */
    public CompositeUI(Composite e, int n){
        pos = n + (n%6)*6;
        comp = e;
        ID = comp.getName();
    }
    /**
     * ID getter metodusa
     * @return 
     */
    public String getID(){
        return ID;
    }
    /**
     * pos getter metodusa
     * @return 
     */
    public int getPos(){
        return pos;
    }
    /**
     * Az elem kirajzolasa
     * @param g 
     */
    public void draw(Graphics g){
        g.drawRect(10+(pos%6)*160, 0+(pos/6)*60, 65, 40);
        g.drawString(comp.getName(), 15+(pos%6)*160, 15+(pos/6)*60);
        if(comp.getName().startsWith("DFF")){
            String sign = comp.getPinByName("PIN04").getOutput().getValue() == true ? "true" : "false";
            g.drawString(sign, 15+(pos%6)*160 ,30+(pos/6)*60);
        }
        if(comp.getName().startsWith("XOR")){
            String sign = comp.getPinByName("PIN03").getOutput().getValue() == true ? "true" : "false";
            g.drawString(sign, 15+(pos%6)*160 ,30+(pos/6)*60);
        }
    }
    /**
     * Esemeny hozzarendelese az elemhez
     */
    public void act(){
        
    }
}
